#include "button.h"
#include <QPaintEvent>
#include <QPainter>

Button::Button(QWidget * parent) : QPushButton(parent), m_isOdd(false)
{
    startTimer(1);
}

QSize Button::sizeHint()
{
    static QSize size(50,50);
    return size;
}

void Button::paintEvent(QPaintEvent * e)
{
    QPainter painter(this);

    if(m_isOdd)
        painter.setBrush(Qt::green);
    else
        painter.setBrush(Qt::blue);
    painter.drawEllipse(e->rect());
}

void Button::timerEvent(QTimerEvent * e)
{
    m_isOdd = !m_isOdd;
    emit update();
}
